<template>
  <div class="item">
    <div class="line active"></div>
      <div class="goods">
        <p class="time">
          <span>今天</span>
          <a href="javascript:;" v-if="todayObj.length">删除</a>
        </p>
        <ul>
          <li v-for="goods in todayObj"  :key="goods.id">
            <i class="close iconfont icon-guanbi"></i>
            <a href="javascript:;">
              <img src="https://yanxuan-item.nosdn.127.net/f7a4f643e245d03771d6f12c94e71214.png" alt="">
              <p class="name ellipsis">{{goods.name}}</p>
              <p class="desc">{{goods.desc}}</p>
              <p class="price">&yen;{{goods.price}}</p>
            </a>
          </li>
        </ul>
      </div>
    </div>
    <div class="item">
      <div class="line"></div>
      <div class="goods">
        <p class="time">
          <span>昨天</span>
          <a href="javascript:;" v-if="yesterdayObj.length">删除</a>
        </p>
        <ul>
          <li v-for="goods in yesterdayObj" :key="goods.id">
            <i class="close iconfont icon-guanbi"></i>
            <a href="javascript:;">
              <img src="https://yanxuan-item.nosdn.127.net/f7a4f643e245d03771d6f12c94e71214.png" alt="">
              <p class="name ellipsis">{{goods.name}}</p>
              <p class="desc">{{goods.desc}}</p>
              <p class="price">&yen;{{goods.price}}</p>
            </a>
          </li>
        </ul>
      </div>
    </div>
    <div class="item">
      <div class="line"></div>
      <div class="goods">
        <p class="time">
          <span>更早之前</span>
          <a href="javascript:;" v-if="longtimeagoObj.length > 0">删除</a>
        </p>
        <ul>
          <li v-for="goods in longtimeagoObj" :key="goods.id">
            <i class="close iconfont icon-guanbi"></i>
            <a href="javascript:;">
              <img src="https://yanxuan-item.nosdn.127.net/f7a4f643e245d03771d6f12c94e71214.png" alt="">
              <p class="name ellipsis">{{goods.name}}</p>
              <p class="desc">{{goods.desc}}</p>
              <p class="price">&yen;{{goods.price}}</p>
            </a>
          </li>
        </ul>
      </div>
    </div>
</template>

<script>
import dayjs from 'dayjs'
import { ref } from 'vue'
export default {
  name: 'FootmarkListItem',
  props: {
    footmark: {
      type: Array,
      default: () => []
    }
  },
  setup (props) {
    const todayObj = ref([])
    const yesterdayObj = ref([])
    const longtimeagoObj = ref([])
    const today = dayjs().hour(0).minute(0).second(0).millisecond(0)
    const yesterday = today.subtract(1, 'day')
    props.footmark.forEach(item => {
      if (dayjs(item.browserTime).isBefore(today)) {
        if (dayjs(item.browserTime).isBefore(yesterday)) {
          longtimeagoObj.value.push(item)
        } else {
          yesterdayObj.value.push(item)
        }
      } else {
        todayObj.value.push(item)
      }
    })
    return { todayObj, yesterdayObj, longtimeagoObj }
  }
}
</script>

<style lang="less" scoped>
  .item {
    display: flex;
    .line {
      width: 27px;
      border-right: 2px solid rgb(245, 245, 245);
      margin-right: 25px;
      position: relative;
      &::before {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        transform: translate(7px);
        border-radius: 50%;
        width: 12px;
        height: 12px;
        background: rgb(228, 228, 228);
      }
    }
    .active::before {
      background: rgb(39, 186, 155);
      z-index: 1;
    }
    .active::after {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      transform: translate(11px, -4px);
      border-radius: 50%;
      width: 20px;
      height: 20px;
      background: rgb(227, 249, 244);
    }
    .goods {
      flex: 1 1 0%;
    .time {
      margin-top: -5px;
      span {
        font-size: 16px;
        color: rgb(153, 153, 153)
      }
      a {
        color: #cf4444!important;
        margin-left: 10px;
      }
    }
    ul {
      display: flex;
      flex-wrap: wrap;
      padding-top: 25px;
      li {
        width: 278px;
        height: 370px;
        padding-top: 25px;
        text-align: center;
        margin-bottom: 25px;
        margin-right: 30px;
        position: relative;
        &:nth-child(3n) {
          margin-right: 0;
        }
        img {
          width: 192px;
          height: 192px;
        }
        .close {
          position: absolute;
          right: 0px;
          top: 0px;
          width: 30px;
          height: 30px;
          background: rgb(228, 228, 228);
          color: rgb(255, 255, 255);
          text-align: center;
          line-height: 30px;
          display: none;
          cursor: pointer;
        }
        &:hover {
          transition: all .5s;
          transform: translate3d(0,-3px,0);
          box-shadow: 0 3px 8px rgba(0,0,0,0.2);
          background: #f0f9f4;
          i {
            display: block;
          }
        }
        .name {
         font-size: 16px;
          padding-top: 15px;
        }
        .desc {
          color: rgb(153, 153, 153);
          padding-top: 18px;
        }
        .price {
          font-size: 18px;
          color: rgb(207, 68, 68);
          padding-top: 24px;
        }
      }
    }
    }
  }
</style>
